<?php
/**
 * Created by PhpStorm.
 * User: Mizuki
 * Date: 2019/7/10
 * Time: 10:42
 */
namespace Api\Logic;

class UserLogic extends BaseLogic {
    /*
     * 用户注册及更新信息
     */
    public function updateInfo() {
        $USER = D('user');
        $idUser = session('uid');
        $info = $USER->getInfoByUid($idUser);
        if ($info == false) {
            return $this->setError('数据库无数据', 101);
        } else {
            $data = I('userBasicInfo');
            $data['gmtModify'] = time();
            $updateResult = $USER->where(['idUser' =>$idUser])->save($data);
            if($updateResult > 0){
                $finalData = $USER->getInfoByUid($idUser);
                return $this->setSuccess('更新成功', 0, $finalData);
            } else {
                return $this->setError('数据库更新失败', 101, $USER->getLastSql());
            }
        }
    }
}